<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  Architecture
-->
<div ng-controller="JVM.ConnectController">

    <div class="row-fluid connect-column-container" hawtio-auto-columns=".connect-column">

        <div class="connect-column">
            <div class="alert alert-info">
                <p>
                    This page allows you to connect to remote processes which <strong>already have a <a
                        href="http://jolokia.org/">jolokia agent</a> running inside them</strong>. You will need to know the
                    host name, port and path of the jolokia agent to be able to connect.
                </p>

                <p>
                    If the process you wish to connect to does not have a jolokia agent inside, please refer to the <a
                        href="http://jolokia.org/agent.html">jolokia documentation</a> for how to add a JVM, servlet or OSGi
                    based agent inside it.
                </p>

                <p ng-show="hasLocalMBean()">
                    Use the <strong><a href="#/jvm/local">Local Tab</a></strong> to connect to processes locally on this machine (which will install a jolokia agent automatically if required).
                </p>

                <p ng-show="!hasLocalMBean()">
                    The <strong>Local Tab</strong> is not currently enabled because either the server side <strong>hawtio-local-jvm-mbean plugin</strong> is not installed or this
                    JVM cannot find the <strong>com.sun.tools.attach.VirtualMachine</strong> API usually found in the <strong>tool.jar</strong>.
                    Please see the <a href="http://hawt.io/faq/index.html">FAQ entry</a> for more details.
                </p>
            </div>
        </div>

        <div class="connect-column">

            <dl>
                <dt>Saved Connections</dt>
                <dd>
                    <form class="form-horizontal no-bottom-margin">
                        <fieldset>
                            <div class="control-group">
                                <label class="control-label">Connections: </label>
                                <div class="controls">
                                    <select ng-model="lastConnection"
                                            ng-options="value.name as key for (key, value) in connectionConfigs">
                                        <option value=""
                                                ng-hide="lastConnection">New connection...</option>
                                    </select>
                                    <button class="btn btn-success"
                                            title="Connect to this server"
                                            ng-disabled="!lastConnection"
                                            ng-click="gotoServer()"><i class="icon-share"></i></button>
                                    <button class="btn btn-danger"
                                            title="Delete this connection"
                                            ng-disabled="!lastConnection"
                                            ng-click="deleteConnection()"><i class="icon-remove-sign"></i></button>
                                    <button class="btn btn-primary"
                                            title="Create a new connection"
                                            ng-disabled="!lastConnection"
                                            ng-click="newConnection()"><i class="icon-plus"></i></button>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </dd>
            </dl>

            <dl>
                <dt>Connection Settings</dt>
                <dd>
                    <div simple-form name="connectForm" data="formConfig" entity="currentConfig" onSubmit="gotoServer()"></div>

                    <div class="centered">
                        <button class="btn btn-primary"
                                ng-disabled="!forms.connectForm.$valid"
                                hawtio-submit="connectForm"
                                title="Saves the connection and opens a new browser window connecting to the given JVM process via its Jolokia servlet URL">Connect to remote server</button>
                        <button class="btn"
                                title="Save this configuration but don't open a new tab"
                                ng-disabled="!forms.connectForm.$valid"
                                ng-click="save()">Save</button>
                    </div>
                </dd>
            </dl>

        </div>

    </div>

</div>